﻿//----------------------------------------------------------------
// Desc: 
// Edit: ShowLong, http://blog.csdn.net/showlong
//
// Date Created: 2014-04-15
//
// Update Date :            
//
// Copyright (c) Fuel4D (http://www.fuel4d.com), All rights reserved.
//
//----------------------------------------------------------------
#pragma once


class FUI_Layout;


class FAPI FUI_Container : public FUI_Object
{
    FUI_DECLARE_CLASS(FUI_Container)

    friend class FUI_System;
    friend class FUI_Frame;
public:
    FUI_Container(EF_UI_WIDGET_TYPE t = eUWT_Container);
    virtual void Release();
    virtual void SetVisible(bool bVis);
    virtual bool PtInObject(funit nX, funit nY);
    virtual FUI_Object* FindObject(funit nX, funit nY);
    virtual bool IsChild(FUI_Object* pChild);
    virtual bool HasClip();
    virtual void Render(EF_UI_RENDER_LAYER layer);
    virtual void UpdateRect();
    virtual bool GetCursorResult(EF_UI_EVENT_TYPE t){ return false; }
    virtual bool OnKeyDown(unsigned int nChar);
    virtual bool OnKeyUp(unsigned int nChar);
    virtual bool OnChar(unsigned int nChar);
    virtual bool OnMouseMove(funit nX, funit nY);
    virtual bool OnMouseWheel(bool bUp, funit nX, funit nY);
    virtual bool OnLButtonDown(funit nX, funit nY);
    virtual bool OnRButtonDown(funit nX, funit nY);
    virtual bool OnLButtonUp(funit nX, funit nY);
    virtual bool OnRButtonUp(funit nX, funit nY);
    virtual bool OnLButtonDBClick(funit nX, funit nY);

protected:
    virtual void InitUIData(FUI_Object* father, fuWidgetBase* pData, FUI_Layout* layout);
    virtual void Update();

public:
    FUI_Object* FindChild(DWORD nWidgetID);
    void FindChild(EF_UI_WIDGET_TYPE type, FV_UI_POBJECT& vRet);
    void RenderHelper(DWORD color);
    void PushVisibleEditObject(FV_UI_POBJECT& buf);

    FINLINE size_t GetCount(){ return vecCtrl.size(); }
    FINLINE FUI_Object* GetSubObject(size_t idx)
    { if (idx >= 0 && idx < vecCtrl.size()) return vecCtrl[idx]; return 0; }

protected:
    fuWidgetContainer* pConData;      // 控件数据地址
    FV_UI_POBJECT vecCtrl;
};
 